<?php
/**
 * Created by PhpStorm.
 * User: user
 * Date: 2016/3/30
 * Time: 16:46
 */

use front\assets\AppAsset;
use yii\helpers\Url;

$base = AppAsset::register($this);
$baseUrl = $base->baseUrl;

$this->title = "申请退换货";

?>


<body class="u-bg1">

<div class="m-ref">

    <div class="desc">
        <img src="<?= $itemInfo['product_pic_url']?>">
        <h6>
            <a href="javascript:;"><?= $itemInfo['product_title']?></a><br>
            <?php if (!empty($itemInfo['data'])) {?>
                <?php foreach($itemInfo['data'] as $k => $v) {?>
                    <?php if ($k != 'product_id') {?>
                        <?= $k?>:<?= $v?>&emsp;
                    <?php }?>
                <?php }?>
            <?php }?>
            <br>
            数量：1
        </h6>
        <span>￥ <b><?= $itemInfo['price']?></b></span>
    </div>

    <dl class="cnt4">
        <dt>服务类型</dt>
        <dd id="J_sltType" type="1">
            <a href="javascript:;" class="z-on" type="1">退货</a>
            <a href="javascript:;" type="2">换货</a>
        </dd>
    </dl>

    <div class="remark">
        <textarea placeholder="商品描述..." id="J_contDesc"></textarea>
        <span>50字</span>
    </div>

<!--    <dl class="cnt5">-->
<!--        <dt>上传图片<small>（最多上传 3 张图片，选传）</small></dt>-->
<!--        <dd>-->
<!--            <img src="img/tmp005.jpg">-->
<!--            <img src="img/tmp005.jpg">-->
<!--            <a class="m-upload-btn" href="javascript:;">-->
<!--                <input type="file" onchange="upfile(this);" accept="image/jpg,image/jpeg,image/png,image/gif" multiple="multiple" /><span>&nbsp;</span>-->
<!--            </a>-->
<!--            <a href="javascript:;">&nbsp;</a>-->
<!--        </dd>-->
<!--    </dl>-->

    <a href="javascript:submit();" class="subi">提交</a>
</div>

<script>
    $(function(){

        $('#J_contDesc').on('keyup', function(){
            var _this = $(this);
            _this.next().text( _this.val().length + '字' );
        })

        //
        var sltBtn = $('#J_sltType'), zon = 'z-on';
        sltBtn.on('tap', 'a', function(){

            var _that = $(this), _parent = _that.parent();

            if(_that.hasClass(zon)) return !1;
            sltBtn.attr('type', _that.attr('type'));

            _that.addClass(zon).siblings('a').removeClass(zon);
        });
    });

    function upfile(ob){

        var dir = ob.value;
        if(dir.length <= 0) return !1;

        var ext = /\.[^\.]+$/.exec(dir)[0];

        if(ext !== '.jpg' || ext !== '.png' || ext !== '.gif'){
            console.log('格式错误');
            return !1;
        }

        // ......
    }

    function submit()
    {
        var type = $('#J_sltType').attr('type');
        var reason = $.trim($('#J_contDesc').val());
        if (reason == "") {
            msgPopup("请填写退货理由，谢谢~");
            return !1;
        }
        $.post("", {apply:true, type:type, reason:reason}, function(data) {
            data = JSON.parse(data);
            if(data.code == 0) {
                window.location.href = '<?=\yii\helpers\Url::to(['returngoods/apply_info','order_id' => $order_id,'product_id' => $product_id])?>';
            }else {
                msgPopup(data.message);
            }
        })
    }
</script>
</body>
















